package com.liqi.web.controller.monitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.liqi.common.utils.poi.ExcelUtil;
import com.liqi.monitor.domain.DvMaitenance;
import com.liqi.monitor.service.IDvMaitenanceService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.liqi.common.annotation.Log;
import com.liqi.common.core.controller.BaseController;
import com.liqi.common.core.domain.AjaxResult;
import com.liqi.common.enums.BusinessType;
import com.liqi.common.core.page.TableDataInfo;

/**
 * 分组Controller
 *
 * @author zhangh
 * @date 2022-10-19
 */
@Api(tags = "维修管理")
@RestController
@RequestMapping("/monitor/maitenance")
public class DvMaitenanceController extends BaseController
{
    @Autowired
    private IDvMaitenanceService dvMaitenanceService;

    /**
     * 查询分组列表
     */
    @ApiOperation("维修管理查询")
    //@PreAuthorize("@ss.hasPermi('monitor:maitenance:list')")
    @GetMapping("/list")
    public TableDataInfo list(DvMaitenance dvMaitenance)
    {
        startPage();
        List<DvMaitenance> list = dvMaitenanceService.selectDvMaitenanceList(dvMaitenance);
        return getDataTable(list);
    }

//    /**
//     * 导出分组列表
//     */
//    @PreAuthorize("@ss.hasPermi('device:group:export')")
//    @Log(title = "分组", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DvMaitenance dvMaitenance)
//    {
//        List<DvMaitenance> list = dvMaitenanceService.selectDvMaitenanceList(dvMaitenance);
//        ExcelUtil<DvMaitenance> util = new ExcelUtil<DvMaitenance>(DvMaitenance.class);
//        util.exportExcel(response, list, "分组数据");
//    }

//    /**
//     * 获取分组详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('device:group:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return AjaxResult.success(dvMaitenanceService.selectDvMaitenanceById(id));
//    }

    /**
     * 新增分组
//     */
    @Log(title = "分组", businessType = BusinessType.INSERT)
    @ApiOperation("维修管理新增")
    //@PreAuthorize("@ss.hasPermi('monitor:maitenance:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DvMaitenance dvMaitenance)
    {
        return toAjax(dvMaitenanceService.insertDvMaitenance(dvMaitenance));
    }

    /**
     * 修改分组
     */
    @ApiOperation("维修管理新增")
    //@PreAuthorize("@ss.hasPermi('monitor:maitenance:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody DvMaitenance dvMaitenance)
    {
        return toAjax(dvMaitenanceService.updateDvMaitenance(dvMaitenance));
    }
//
//    /**
//     * 删除分组
//     */
//    @PreAuthorize("@ss.hasPermi('device:group:remove')")
//    @Log(title = "分组", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(dvMaitenanceService.deleteDvMaitenanceByIds(ids));
//    }
}
